Hệ thống quản lý ISP trong PHP
1 <?php include 'includes/header.php'; ?>
2 <?php
3 require_once "includes/classes/admin-class.php";
4 $admins = new Admins($dbh);
5 if (isset($_POST['quantity'])) {
6 $proselect = $_POST['proselect'];
7 $quantity = $_POST['quantity'];
8 $date = $_POST['date'];
9 $provider = $_POST['provider'];
10 $recipient = $_POST['recipient'];
11 $remarks = $_POST['remarks'];
12 $type = $_POST['type'];
13 if (!$admins->insertProductData($proselect, $quantity, $date, $provider, $recipient, $remarks, $type))
14 {
15 $msg = "<i class=\"warning\">Sorry Data could not be inserted !</i>";
16 }else {
17 $msg = "<i class=\"success\">Well! You've successfully inserted new data!</i>";
18 }
19 }
20 $page = isset($_GET[ 'p' ])?$_GET[ 'p' ]:'';
21 if($page == 'del'){
22 $id = $_POST['id'];
23 if (!$admins->deleteProduction($id))
24 {
25 $msg = "Sorry Data could not be deleted !";
26 }else {
27 $msg = "Well! You've successfully deleted a product!";
28 }
29 }
30 ?>
31 <!-- Recieve products -->
32 <div class="col-md-12 col-sm-12">
33 <div class="panel panel-default">
34 <div class="panel-heading">
35 <h5>Recieve Products : <?php if (isset($msg)) {echo "$msg";} ?></h5>
36 </div>
37 <div class="panel-body">
38 <div class="col-md-12">
39 <form class="form-inline" action="production.php" method="POST">
40 <input type="hidden" name="type" value="1">
41 <input type="hidden" name="recipient" value="">
42 <div class="form-group">
43 <label for="proselect"></label>
44 <select class="form-control select-form-control" name="proselect" id="proselect" required>
45 <option selected disabled value="" ="">Select a product</option>
46 <?php $products = $admins->fetchProducts();
47 if (isset($products) && sizeof($products) > 0){
48 foreach ($products as $product) { ?>
49 <option value='<?=$product->pro_id?>'><?=$product->pro_name?></option>
50 <?php }} ?>
51 </select>
52 </div>
53 <div class="form-group">
54 <label class="sr-only" for="date">Date</label>
55 <input type="date" class="form-control" name="date" id="date" value="<?php echo date("Y-m-d"); ?>">
56 </div>
57 <div class="form-group">
58 <label class="sr-only" for="quantity">Quantity</label>
59 <input type="number" class="form-control" name="quantity" id="quantity" placeholder="Quantity" required="">
60 </div>
61 <div class="form-group">
62 <label class="sr-only" for="provider">Provider</label>
63 <input type="text" class="form-control" name="provider" id="provider" placeholder="prodiver" required="">
64 </div>
65 <div class="form-group">
66 <label class="sr-only" for="remarks">Remarks</label>
67 <input type="text" class="form-control" name="remarks" id="remarks" placeholder="Remarks" >
68 </div>
69 <button type="submit" class="btn btn-primary">RECEIVE</button>
70 </form>
71 <br>
72 <table id="grid-basic" class="table table-striped table-bordered">
73 <thead class="thead-inverse">
74 <tr class="info">
75 <th data-column-id="id" data-type="numeric">ID </th>
76 <th data-column-id="date" data-type="date">Date</th>
77 <th data-column-id="name" data-type="text">Product Name</th>
78 <th data-column-id="production" data-type="numeric">Quantity</th>
79 <th data-column-id="finished" data-type="text">Provider</th>
80 <th data-column-id="unfinished" data-type="text">Remarks</th>
81 <th data-column-id="commands" data-formatter="commands" data-sortable="false">Action</th>
82 </tr>
83 </thead>
84 <tbody>
85 <?php
86 $products = $admins->fetchProduction();
87 if (isset($products) && sizeof($products) > 0){
88 foreach($products as $product) {
89 $proID = $product->product_id;
90 $proName = $admins->getAProduct($proID);
91 $product_name = $proName->pro_name;
92 ?>
93 <tr>
94 <td><?=$product->id?></td>
95 <td><?=date("jS F y",strtotime($product->cdate))?></td>
96 <td><?php echo $product_name; ?></td>
97 <td><?=$product->quantity?></td>
98 <td><?=$product->provider?></td>
99 <td><?=$product->remarks?></td>
100 <td><button type="button" data-id="<?=$product->id?>" class="btn btn-danger btn-sm delete">DELETE</button></td>
101 </tr>
102 <?php }} ?>
103 </tbody>
104 </table>
105 </div>
106 </div>
107 </div>
108 </div>
109
110
111
112 <!-- Send products -->
113 <div class="col-md-12 col-sm-12">
114 <div class="panel panel-default">
115 <div class="panel-heading">
116 <h5>Send Products : <?php if (isset($msg)) {echo "$msg";} ?></h5>
117 </div>
118 <div class="panel-body">
119 <div class="col-md-12">
120 <form class="form-inline" action="production.php" method="POST">
121 <input type="hidden" name="type" value="0">
122 <input type="hidden" name="provider" value="">
123 <div class="form-group">
124 <label for="proselect"></label>
125 <select class="form-control select-form-control" name="proselect" id="proselect" required>
126 <option selected disabled value="" ="">Select a product</option>
127 <?php $products = $admins->fetchProducts();
128 if (isset($products) && sizeof($products) > 0){
129 foreach ($products as $product) { ?>
130 <option value='<?=$product->pro_id?>'><?=$product->pro_name?></option>
131 <?php }} ?>
132 </select>
133 </div>
134 <div class="form-group">
135 <label class="sr-only" for="date">Date</label>
136 <input type="date" class="form-control" name="date" id="date" value="<?php echo date("Y-m-d");?>">
137 </div>
138 <div class="form-group">
139 <label class="sr-only" for="quantity">Quantity</label>
140 <input type="number" class="form-control" name="quantity" id="quantity" placeholder="Quantity" required="">
141 </div>
142 <div class="form-group">
143 <label class="sr-only" for="recipient">Recipient</label>
144 <input type="text" class="form-control" name="recipient" id="recipient" placeholder="recipient" required="">
145 </div>
146 <div class="form-group">
147 <label class="sr-only" for="remarks">Remarks</label>
148 <input type="text" class="form-control" name="remarks" id="remarks" placeholder="Remarks" >
149 </div>
150 <button type="submit" class="btn btn-primary">SEND</button>
151 </form>
152 <br>
153 <table id="grid-basic" class="table table-striped table-bordered">
154 <thead class="thead-inverse">
155 <tr class="info">
156 <th data-column-id="id" data-type="numeric">ID </th>
157 <th data-column-id="date" data-type="date">Date</th>
158 <th data-column-id="name" data-type="text">Product Name</th>
159 <th data-column-id="production" data-type="numeric">Quantity</th>
160 <th data-column-id="unfinished" data-type="text">Recipient</th>
161 <th data-column-id="unfinished" data-type="text">Remarks</th>
162 <th data-column-id="commands" data-formatter="commands" data-sortable="false">Action</th>
163 </tr>
164 </thead>
165 <tbody>
166 <?php
167 $products = $admins->fetchProductionSend();
168 if (isset($products) && sizeof($products) > 0){
169 foreach($products as $product) {
170 $proID = $product->product_id;
171 $proName = $admins->getAProduct($proID);
172 $product_name = $proName->pro_name;
173 ?>
174 <tr>
175 <td><?=$product->id?></td>
176 <td><?=date("jS F y",strtotime($product->cdate))?></td>
177 <td><?php echo $product_name; ?></td>
178 <td><?=$product->quantity?></td>
179 <td><?=$product->recipient?></td>
180 <td><?=$product->remarks?></td>
181 <td><button type="button" data-id="<?=$product->id?>" class="btn btn-danger btn-sm delete">DELETE</button></td>
182 </tr>
183 <?php }} ?>
184 </tbody>
185 </table>
186 </div>
187 </div>
188 </div>
189 </div>
190
191
192
193
194 <?php include 'includes/footer.php'; ?>
195 <script type="text/javascript">
196 document.getElementById('date').valueAsDate = new Date();
197 $('table').on('click', '.delete', function(e){
198 var id = $(this).attr("data-id");
199 var tr = $(this).closest("tr");
200 $.ajax({
201 method:"POST",
202 url: "production.php?p=del",
203 data: "id="+id,
204 success: function (data){
205 //alert(id);
206 //$tr.remove();
207 }
208 });
209 $(this).closest('tr').fadeOut(500);
210 });
211 </script>